home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 016a / gofer221.zip / CH04 < prev    next >
Text File  |  1991-11-20  |  2KB  |  67 lines

  1.  
  2.  
  3. Introduction to Gofer         4. USING GOFER - A BASIC INTRODUCTION             
  4.  
  5.  
  6. 4. USING GOFER - A BASIC INTRODUCTION
  7.  
  8. Using Gofer is rather like using a high-level programmable  calculator;
  9. Once the interpreter is loaded, the system  prints  a  prompt  "?"  and
  10. waits for you to enter an expression, and then press the enter (return)
  11. key.  Once the input is complete, Gofer evaluates  the  expression  and
  12. prints its value on the terminal,  before  returning  to  the  original
  13. prompt and waiting for the next expression.  For example:
  14.  
  15.     ? (2+3)*8
  16.     40
  17.     (5 reductions, 9 cells)
  18.     ? sum [1..10]
  19.     55
  20.     (91 reductions, 130 cells)
  21.     ? 
  22.  
  23. In the first example, the user entered the expression "(2+3)*8",  which
  24. was evaluated by Gofer and the result "40" printed on the terminal.  At
  25. the end of any calculation, Gofer displays the number of reductions  (a
  26. measure of the amount of work) and cells (a measure of  the  amount  of
  27. memory) that were used during the calculation.  These  figures  can  be
  28. useful for comparing the performance of different ways of carrying  out
  29. the same calculation.
  30.  
  31. In the second example, the user typed  the  expression  "sum  [1..10]".
  32. The notation "[1..10]" represents the list of integers between 1 and 10
  33. inclusive, and "sum" is a  standard  function  which  can  be  used  to
  34. determine the sum of a list of integers.  Thus the result  obtained  by
  35. Gofer is:
  36.  
  37.           1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10  =  55
  38.  
  39. We could have typed this sum into Gofer directly:
  40.  
  41.     ? 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10
  42.     55
  43.     (10 reductions, 23 cells)
  44.     ? 
  45.  
  46. and this calculation is certainly more efficient as it uses only  1/9th
  47. of the number of reductions and 1/5th of the number  of  cells  as  the
  48. original calculation.  On the other hand, the  original  expression  is
  49. much shorter and you are much less likely to make a mistake  typing  in
  50. the expression "sum [1..200]" than you would be if you tried  to  enter
  51. the sum of the integers from 1 to 200 directly.
  52.  
  53. You will learn more about the kind of expressions that can  be  entered
  54. into Gofer in the rest of this document.
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.                                       5
  65.  
  66.  
  67.